
<div  ng-controller="backendUserCtrl">

    <div class="form-group">
        <form action="">
            <label class="control-label" for="textinput">小区:</label>
            <!--<select ng-model="communityId" ng-options="m.objId as m.communityName for m in communityLabelList.data"-->
            <!--ng-change="getActivityList(communityId,level,description)">-->
            <!--<option value="">&#45;&#45; 请选择 &#45;&#45;</option>-->
            <!--</select>-->
            <input type = "text" id = "community_select" ng-model="communityId" value = "">
            <label class="control-label">身份:</label>

            <select id="roleSelect" ng-model="role">
                <option></option>
                <option>Admin</option>
                <option>Operation</option>
                <option>Service</option>
                <option>Guest</option>
                <option>moderator</option>
                <option>Property</option>
            </select>
            <span style="font-weight:bold">&nbsp;&nbsp;&nbsp;用户名 &nbsp;<input type="text" ng-model="loginName"
                                                                  placeholder=""></span>
            <button style="margin-left: 20px;" type="submit" class="btn-secondary btn-sm" ng-click="getAdminUserList(communityId, role, loginName)">搜索</button>
        </form>
    </div>
    <!--<br>-->
    <div>
        <br>
        <a ng-click="addUser()" class="btn-primary btn-sm nodecoration">新建用户</a>
        <br>
        <br>
        <paging>
            <ul class="pagination" num-pages="tasks.pageCount" current-page="tasks.currentPage"
                on-select-page="selectPage(page)">
                <li ng-class="{disabled: noPrevious()}"><a ng-click="selectPrevious()">&laquo;</a>

                </li>
                <li ng-repeat="page in pages" ng-class="{active: isActive(page)}"><a
                        ng-click="selectPage(page)">{{page}}</a>

                </li>
                <li ng-class="{disabled: noNext()}"><a ng-click="selectNext()">&raquo;</a>

                </li>
                <li ng-show="currentPage>6"><a ng-click="selectPage(1)">首页</a>

                </li>
            </ul>
        </paging>
        <table class="table table-condensed" width="647">
            <thead>
            <tr>
                <th width="15%">用户ID</th>
                <th width="30%">用户名</th>
                <th width="20%">身份</th>
                <th width="15%">密码</th>
                <th width="15%">应用登录名</th>
                <th width="15%">小区</th>
                <th width="20%" class="align-right">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="backendUser in backendUserList">
                <td>{{backendUser.loginId}}</td>
                <td>{{backendUser.userName}}</td>
                <td>{{backendUser.role}}</td>
                <td>********</td>
                <td>{{backendUser.appuser.mobilePhone}}</td>
                <td >
                    <div ng-repeat="community in backendUser.communities"><span>{{community.communityName}}</span></div>
                </td>
                <td class="align-right">
                    <a class="btn btn-danger btn-xs" ng-show="backendUser.role!=='Service'||!backendUser.signed" ng-click="updateUser(backendUser.loginId)">Edit</a>
                    <a class="btn btn-danger btn-xs"  ng-click="deleteUser(backendUser.loginId)" ng-show="backendUser.loginId!='admin'&&backendUser.role!=='Service'||!backendUser.signed">Delete</a>
                </td>
            </tr>
            <tr>
                <td colspan="5" align="center" ></td>
            </tr>
            </tbody>
        </table>
        <paging>
            <ul class="pagination" num-pages="tasks.pageCount" current-page="tasks.currentPage"
                on-select-page="selectPage(page)">
                <li ng-class="{disabled: noPrevious()}"><a ng-click="selectPrevious()">&laquo;</a>

                </li>
                <li ng-repeat="page in pages" ng-class="{active: isActive(page)}"><a
                        ng-click="selectPage(page)">{{page}}</a>

                </li>
                <li ng-class="{disabled: noNext()}"><a ng-click="selectNext()">&raquo;</a>

                </li>
                <li ng-show="currentPage>6"><a ng-click="selectPage(1)">首页</a>

                </li>
            </ul>
        </paging>
    </div>


    <div class="modal fade" id="user_modal" tabindex="-1"  role="dialog" aria-labelledby="helpModalLabel"  aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h5 class="modal-title" id="myModalLabel">{{popupTitle}}</h5>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" name="backendUserForm">
                        <div class="form-group">
                            <label for="inputLoginId" class="control-label col-xs-2">用户ID:</label>
                            <div class="col-xs-3">
                                <input type="text" class="form-control"  ng-model="backendUser.loginId" id="loginId" required placeholder="loginId">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputUserName" class="control-label col-xs-2">用户名:</label>
                            <div class="col-xs-3">
                                <input type="text" class="form-control" ng-model="backendUser.userName" id="userName" required placeholder="userName">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-xs-2" for="role">身份:</label>
                            <div class="col-xs-2">
                                <select id="role_select" class="form-control" ng-model="backendUser.role" placeholder="UserRole"  ng-change="roleChange()" required tabindex="4">
                                    <option></option>
                                    <option>Admin</option>
                                    <option>Operation</option>
                                    <option>Service</option>
                                    <option>Guest</option>
                                    <option>moderator</option>
                                    <option>Property</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group" ng-show="oldPasswordDisplay">
                            <label class="control-label col-xs-2">原密码:</label>
                            <div class="col-xs-4">
                                <input type="password" class="form-control" id="old_password" ng-model="backendUser.oldPassword" required placeholder="如改密码请输入">
                            </div>
                        </div>
                        <div class="form-group"  ng-class="{ 'has-error' : backendUserForm.password.$invalid && !backendUserForm.password.$pristine }">
                            <label for="inputPassword" class="control-label col-xs-2">新密码:</label>
                            <div class="col-xs-4">
                                <input type="password" class="form-control" id="newPassword" ng-model="backendUser.newPassword" name="password" ng-minlength="6" ng-maxlength="16" required placeholder="Password" ng-change="changePasswordValue()">
                                <!--ng-model="backendUser.password"-->
                            </div>
                            <p ng-show="backendUserForm.newPassword.$error.minlength" class="help-block">Password is too short.</p>
                            <p ng-show="backendUserForm.newPassword.$error.maxlength" class="help-block">Password is too long.</p>
                        </div>
                        <div class="form-group"  ng-class="{ 'has-error' : backendUserForm.newPassword2.$invalid && !backendUserForm.newPassword2.$pristine  }">
                            <label for="inputPassword2" class="control-label col-xs-2">再输入一遍:</label>
                            <div class="col-xs-4">
                                <input type="password" class="form-control" id="inputPassword2" ng-model="backendUser.newPassword2" name="newPassword2" ng-minlength="6" ng-maxlength="16"  required placeholder="Password Repeat" ng-change="changePassword2Value()">
                            </div>
                            <p ng-show="backendUserForm.newPassword2.$error.minlength" class="help-block">Password is too short.</p>
                            <p ng-show="backendUserForm.newPassword2.$error.maxlength" class="help-block">Password is too long.</p>
                            <p ng-show="matchFlag==false" class="help-block">Password match error.</p>
                        </div>
                        <div id="service_options" ng-show="backendUser.role=='Service'||backendUser.role=='Guest' || backendUser.role=='moderator'|| backendUser.role=='Property'" class="form-group">
                            <label  class="control-label col-xs-2" >选择小区:</label><br><br>
                            <div style="width:500px;margin-left: 180px;" class = "communitys-select">
                                <input type="text" ng-model="cname" class="form-control" id = "cname_filter" ng-change="cnameFilter(cname)" placeholder="搜索小区" style = "width: 200px;">
                                <table id="manyCommunity" border="0" style="width: 100%;">
                                    <tr align="center">
                                        <td width = "200">
                                            <select id="communities_select" multiple="multiple" ng-model="oneCommunity"
                                                    style="width: 200px;height:300px;">
                                                <!--<option ng-repeat="comm in commList" value="{{comm.objId}}">{{comm.communityName}}</option>-->
                                            </select>
                                            <!--| filter:cname-->
                                        </td>
                                        <td width = "100">
                                            <input type="button" value=">>" id="addAllCommunity" ng-click="addAllCommunity()" /><br /><br />
                                            <input type="button" value=">" id="addCommunity" ng-click="addCommunity()" /><br /><br />
                                            <input type="button" value="<" id="removeCommunity" ng-click="removeCommunity()"/><br /><br />
                                            <input type="button" value="<<" id="removeAllCommunity" ng-click="removeAllCommunity()"/>
                                        </td>
                                        <td>
                                            <select id="selCommunitys" multiple="multiple"
                                                    style="width: 200px;height:300px;" ng-model="crule.community_id">
                                            </select>
                                        </td>

                                    </tr>
                                </table>
                            </div>

                            <label  ng-show="backendUser.role=='Service'"   class="control-label col-xs-2" class="form-control">66客服用户:</label>
                            <div  ng-show="backendUser.role=='Service'"  class="col-xs-4">
                                <select id="user_select" style="width:200px"  SIZE=5>

                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label  ng-show="backendUser.role=='moderator'|| backendUser.role=='Property'"   class="control-label col-xs-2" class="form-control">应用登录ID:</label>
                            <div  ng-show="backendUser.role=='moderator'|| backendUser.role=='Property'"  class="col-xs-3">
                                <input type="text" class="form-control" ng-model="appUser" id="Appuser">
                            </div>
                        </div>

                        <div class="modal-footer">
                            <button id="saveButton" type="submit" class="btn btn-default" ng-click="saveAdd(backendUser)">保存</button>
                            <button id="updateButton" type="submit" class="btn btn-default" ng-click="saveUpdate(backendUser.loginId,backendUser)">修改</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>